package com.zx.servicelearn.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.widget.TextView;

/**
 * Created by zhoux on 2018/1/17.
 * 注释：
 */

public class User implements Parcelable {

    public int userId;
    public String userName;
    public int sex;

    public Book book;

    public User(int userId, String userName, int sex) {
        this.userId = userId;
        this.userName = userName;
        this.sex = sex;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.userId);
        dest.writeString(this.userName);
        dest.writeParcelable(this.book, flags);
    }

    public User() {
    }

    protected User(Parcel in) {
        this.userId = in.readInt();
        this.userName = in.readString();
        this.book = in.readParcelable(Book.class.getClassLoader());
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel source) {
            return new User(source);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };

    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                ", userName='" + userName + '\'' +
                ", sex=" + sex +
                ", book=" + book +
                '}';
    }
}
